import 'package:equatable/equatable.dart';
import 'package:backend.core/core/domain/entities/api/app_store/api_app_store_transaction_ownership_type.dart';

const kPurchaseApiAppStoreTransactionOwnershipTypeValue = 'purchase';
const kFamilySharingApiAppStoreTransactionOwnershipTypeValue = 'family_sharing';

class ApiAppStoreTransactionOwnershipTypeDto extends Equatable {
  const ApiAppStoreTransactionOwnershipTypeDto._internal({
    required this.ownershipTypeString,
  });

  final String ownershipTypeString;

  @override
  List<Object?> get props {
    return [
      ownershipTypeString,
    ];
  }

  factory ApiAppStoreTransactionOwnershipTypeDto.fromEntity(
      ApiAppStoreTransactionOwnershipType ownershipType) {
    late final String ownershipTypeString;

    if (ownershipType == ApiAppStoreTransactionOwnershipType.purchase) {
      ownershipTypeString = kPurchaseApiAppStoreTransactionOwnershipTypeValue;
    } else if (ownershipType == ApiAppStoreTransactionOwnershipType.familySharing) {
      ownershipTypeString = kFamilySharingApiAppStoreTransactionOwnershipTypeValue;
    }

    return ApiAppStoreTransactionOwnershipTypeDto._internal(
      ownershipTypeString: ownershipTypeString,
    );
  }

  @override
  String toString() {
    return ownershipTypeString;
  }
}
